package com.itheima.mode_test;

import lombok.Data;

/**
 * @author ：yuan_he_song
 * 具体观察者
 */
@Data
public class User implements Observer{
    private String name;
    private Integer id;
    public User(String name){
        this.name = name;
    }
    public User(Integer id){
        this.id = id;
    }
    public User(Integer id,String name){
        this.id = id;
        this.name = name;
    }

    @Override
    public void update(String msg) {
        System.out.println(name + "收到消息:" + msg);
    }

    public static void main(String[] args) {
        User u1 = new User("张三");
        User u2 = new User("李四");
        User u3 = new User("王五");
        WeChat weChat = new WeChat();
        weChat.register(u1);
        weChat.register(u2);
        weChat.register(u3);
        weChat.setInfo("PHP是世界上最好的语言");
        System.out.println("============================");
        weChat.remove(u1);
        weChat.setInfo("JAVA是世界上最好的语言");
    }
}
